Repository navigation
Conversation
Call the init function of the serial port used for logging. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Add driver for the qemu debug console (-device isa-debugcon). The iobase passed to UartQemuDebug::new() must match the iobase set for the isa-debugcon device. By convention 0x402 is used for firmware logging. Calling init() is mandatory, this will detect whenever the device is present or not. Logging happens only in case the device has been detected. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
⌛ QEMU Validation PendingQEMU validation is pending on successful CI completion.
This comment was automatically generated by the Patina QEMU PR Validation workflow. |
os-d
left a comment
There was a problem hiding this comment.
Hey Gerd, thanks for the contribution!
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| // read value indicating the device is present | ||
| const PROBE: u8 = 0xe9; | ||
|
|
||
| pub const fn new(io_base: u16) -> Self { |
There was a problem hiding this comment.
nit: (from CI) - public functions need documentation. see: Documenting Quick Reference
|
|
||
| use core::arch::asm; | ||
|
|
||
| /// qemu debug console |
There was a problem hiding this comment.
We'll generally want to add a fuller description for public types since the doc comment ends up in published documentation on the type.
For example, these docs for Uart16550 describe some background and safety instructions to supplement the code: https://docs.rs/patina/latest/patina/peripheral/serial/uart/enum.Uart16550.html
This would also be a good place to mention that reading is not supported.
| // read value indicating the device is present | ||
| const PROBE: u8 = 0xe9; | ||
|
|
||
| pub const fn new(io_base: u16) -> Self { |
There was a problem hiding this comment.
We would normally make this unsafe with a SAFETY section like that lists valid I/O port guidance.
Like this from Uart16550::new_io:
/// # Safety
///
/// The caller must ensure `base` points to a valid Uart16550 I/O port range and that
/// the caller has the rights to perform the I/O operations on it, for as long as the
/// returned value is used.
|
|
||
| fn outb(&self, value: u8) { | ||
| // SAFETY: write output byte to isa-debugcon device | ||
| unsafe { asm!("outb %al, %dx", in("al") value, in("dx") self.io_base, options(att_syntax)) } |
There was a problem hiding this comment.
We don't typically use att_syntax, so considering how minimal this line is, i'd use the default intel syntax.
Additionally, consider adding the nomem, nostack, & preserves_flags to optimize.
| // SAFETY: read device detection byte from isa-debugcon device | ||
| unsafe { | ||
| let ret: u8; | ||
| asm!("inb %dx, %al", in("dx") self.io_base, out("al") ret, options(att_syntax)); |
There was a problem hiding this comment.
Same comment about att_syntax and other flags
There was a problem hiding this comment.
It would be nice to advertise that this available in the DXE Core integration example in the mdbook by updating this comment to include UartQemuDebug:
patina/docs/src/integrate/dxe_core.md
Line 370 in 1f69e13
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
Once QE passes I'll go squash all the incremental fixes, probably next week. |
|
@kraxel, please add unit tests. We can't merge unless code coverage is 80% or higher. You can also disable coverage using |
Given these are just wrappers around IO port writes, I don't think there is value in testing it and having the module covered with coverage(off) would make sense. |
Description
Add driver for the qemu debug console (-device isa-debugcon).
How This Was Tested
kraxel/edk2@4fda393